# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=py3-yaml
_pkgname=PyYAML
pkgver=6.0.1
pkgrel=3
pkgdesc="Python3 bindings for YAML"
url="https://pyyaml.org/"
arch="all"
license="MIT"
makedepends="
	cython
	py3-gpep517
	py3-setuptools
	py3-wheel
	python3-dev
	yaml-dev
	"
subpackages="$pkgname-pyc"
source="$_pkgname-$pkgver.tar.gz::https://github.com/yaml/pyyaml/archive/$pkgver.tar.gz
	cython3.patch
	"
builddir="$srcdir/pyyaml-$pkgver"

replaces="py-yaml" # Backwards compatibility
provides="py-yaml=$pkgver-r$pkgrel" # Backwards compatibility

# secfixes:
#   5.4-r0:
#     - CVE-2020-14343
#   5.3.1-r0:
#     - CVE-2020-1747

prepare() {
	default_prepare
	rm -f ext/_yaml.c
}

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 setup.py test
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
1c74a92a4ad7d47854dc7bcb2e89b3c8e0b14fa815c7dbfbc22b24480dbba6c81e971c77ee384c494a960914b95f06edf943d7431925a5ed674a0ba830d258e0  PyYAML-6.0.1.tar.gz
73c76d8e1f83a5b938bdf2c2ff7503db5c0391b8c90a3c2b60049ba0c2f62e6b541c1ed68093c24eb3675dcffbe8d27289ae0966a0bf8b076f35ca98396f1e17  cython3.patch
"
